<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center shareApp_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub shareApp_fd0_0'>
					<view class='flex flex-wrap align-center shareApp_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  shareApp_fd0_0_c0_c0'>&#xe794;</text>
					</view>
					<text class='shareApp_fd0_0_c1'>分享</text>
					<view class='flex flex-wrap align-center shareApp_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout shareApp_flex_1">
				<view class='flex flex-direction flex-wrap align-center shareApp_fd1_0'>
					<image class='shareApp_fd1_0_c0' mode="aspectFit" :src='dataQrcode.url'
						@tap.stop="singleImagePreview(dataQrcode.url)"></image>
					<!-- <button class='shareApp_fd1_0_c1' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/my/myInvitation/myInvitation`">我的邀请</button> -->
					<view class='flex flex-wrap align-center shareApp_fd1_0_c2'>
						<button class='shareApp_fd1_0_c2_c0' @tap.stop="getSharingFunc()">立即分享</button>
						<button class='shareApp_fd1_0_c2_c1' @tap.stop="saveHttpImgFunc()">保存图片到相册</button>
					</view>
				</view>
				<view class='flex flex-direction flex-wrap align-stretch shareApp_fd1_1' v-if="switchData.switch != 1">
					<view class='flex flex-wrap align-center justify-center'>
						<image class='shareApp_fd1_1_c0_c0' mode="aspectFit" :src='STATIC_URL+"227.png"'></image>
						<text class='shareApp_fd1_1_c0_c1'>规则提示</text>
						<image class='shareApp_fd1_1_c0_c0' mode="aspectFit" :src='STATIC_URL+"228.png"'></image>
					</view>
					<scroll-view class='shareApp_fd1_1_c1' :scroll-y='true'>
						<view class='flex benben-scroll flex align-center'>
							<jyf-parser class='shareApp_fd1_1_c1_c0' :html="dataArtile.body | richTextFormat">
							</jyf-parser>
						</view>
					</scroll-view>
				</view>
			</view>

			<!---flex布局flex布局结束-->
			<benben-popup v-model="popupShow1679736056917" :mask="true" :mask-close-able="true" mode='bottom'>
				<!---分享弹窗flex布局开始-->
				<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout shareApp_flex_2">
					<text class='shareApp_fd2_0'>分享至</text>
					<view class='flex flex-wrap align-center justify-between shareApp_fd2_1'>
						<view class='flex flex-direction flex-wrap align-center' @tap.stop="shareWxFunc()">
							<image class='shareApp_fd2_1_c0_c0' mode="aspectFit" :src='STATIC_URL+"229.png"'></image>
							<text class='shareApp_fd2_1_c0_c1'>微信好友</text>
						</view>
						<view class='flex flex-direction flex-wrap align-center' @tap.stop="shareCircleFunc()">
							<image class='shareApp_fd2_1_c0_c0' mode="aspectFit" :src='STATIC_URL+"230.png"'></image>
							<text class='shareApp_fd2_1_c0_c1'>微信朋友圈</text>
						</view>
					</view>
					<button class='shareApp_fd2_2' @tap.stop="popupShow1679736056917=false">取消</button>
				</view>

				<!---分享弹窗flex布局结束-->

			</benben-popup>


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"popupShow1679736056917": false,
				"switchData": {
					"aid": "",
					"sys_num": "",
					"sys_time": ""
				},
				"dataQrcode": {
					"invite_code": "",
					"user_id": "",
					"url": "",
					"avatar": "",
					"real_name": "",
					"filepath": "",
					"content": "",
					"nickname": "",
					"title": ""
				},
				"dataArtile": {
					"aid": "",
					"title": "",
					"body": "",
					"create_time": ""
				}
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
			/**
			 * @returns 
			 * Android       安卓
			 * IOS       苹果
			 * Web       H5 或 pc
			 * Wechat       微信小程序
			 * Alipay       支付宝小程序
			 * Baidu       百度小程序
			 * ByteBounce       抖音小程序
			 * 360       360小程序
			 * FastApp       快应用
			 */
			appSystemIdentification() {
				return this.$store.state.appSystemIdentification
			}
		},
		watch: {},
		onLoad(options) {
			this.DataArtileFunc()
			this.DataQrcodeFunc()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.getSwitchFunc()
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//获取上架开关
			async getSwitchFunc() {
				//请求方法
				//数据验证

				let dataswitchData = await this.$api.get(global.apiUrls.post643e0feac967e, {

				});

				if (dataswitchData.data.code != 1) {
					this.$message.info(dataswitchData.data.msg);
					return
				}
				let infoswitchData = dataswitchData.data;
				this.switchData = infoswitchData.data
			},
			//获取分享规则
			async DataArtileFunc() {
				//请求方法
				//数据验证

				let datadataArtile = await this.$api.post(global.apiUrls.post636c78ae2216b, {
					aid: '3'
				});

				if (datadataArtile.data.code != 1) {
					this.$message.info(datadataArtile.data.msg);
					return
				}
				let infodataArtile = datadataArtile.data;
				this.dataArtile = infodataArtile.data

			},
			//获取二维码
			async DataQrcodeFunc() {
				//请求方法
				//数据验证

				let datadataQrcode = await this.$api.get(global.apiUrls.post63a6ca64aa13a, {

				});

				if (datadataQrcode.data.code != 1) {
					this.$message.info(datadataQrcode.data.msg);
					return
				}
				let infodataQrcode = datadataQrcode.data;
				this.dataQrcode = infodataQrcode.data

			},
			//保存分享二维码至手机相册
			saveHttpImgFunc() {
				if (!this.setCheckPermission(6)) {
					return
				}
				uni.showLoading({
					title: '二维码下载中'
				});
				uni.downloadFile({
					url: this.dataQrcode.url,
					success: (res) => {
						if (res.statusCode === 200) {
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success: () => {
									uni.hideLoading();
									this.$message.info("图片已保存");
								},
								fail: () => {
									uni.hideLoading();
									this.$message.info("保存失败");
								},
								complete: () => {
									uni.hideLoading();
								}
							});
						}
					},
					fail: error => {
						this.$message.info("保存失败");
					}
				});
			},
			//app或小程序分享
			getSharingFunc() {
				if (this.appSystemIdentification != 'Wechat') {
					this.popupShow1679736056917 = true
				} else if (this.appSystemIdentification == 'Wechat') {
					uni.downloadFile({
						url: this.dataQrcode.url,
						success: (res) => {
							if (res.statusCode === 200) {
								wx.showShareImageMenu({
									path: res.tempFilePath,
									success: (res) => {
										console.log("分享成功：", res);
									},
									fail: (err) => {
										console.log("分享取消：", err);
									},

								})
							}
						},
						fail: error => {
							this.$message.info("保存失败");
						}
					});
				}
			},
			//分享微信聊天
			async shareWxFunc() {
				await this.syncUniApi('share', {
					'provider': 'weixin',
					'scene': 'WXSceneSession',
					'type': 0,
					'title': this.dataQrcode.title,
					'href': this.dataQrcode.filepath,
					'summary': this.dataQrcode.content,
					'imageUrl': this.dataQrcode.url
				})
			},
			//分享朋友圈
			async shareCircleFunc() {
				await this.syncUniApi('share', {
					'provider': 'weixin',
					'scene': 'WXSceneTimeline',
					'type': 0,
					'title': this.dataQrcode.title,
					'href': this.dataQrcode.filepath,
					'summary': this.dataQrcode.content,
					'imageUrl': this.dataQrcode.url
				})
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(206, 7, 53, 1);
		background-size: 100% auto;
	}

	.shareApp_flex_0 {
		background: rgba(206, 7, 53, 1);
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.shareApp_fd0_0_c1 {
		font-size: 36rpx;
		font-weight: 500;
		color: #fff;
	}

	.shareApp_fd0_0_c0_c0 {
		font-size: 32rpx;
		color: #fff;
	}

	.shareApp_fd0_0_c0 {
		width: 120rpx;
		height: 88rpx;
	}

	.shareApp_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.shareApp_flex_1 {
		padding: 0rpx 18rpx 0rpx 19rpx;
	}

	::v-deep .shareApp_fd1_1_c1_c0 {
		width: 100%;
	}

	.shareApp_fd1_1_c1 {
		touch-action: none;
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.shareApp_fd1_1_c0_c1 {
		color: #FAD7AD;
		font-size: 32rpx;
		font-weight: 700;
		line-height: 45rpx;
		margin: 0rpx 20rpx 0rpx 20rpx;
	}

	.shareApp_fd1_1_c0_c0 {
		width: 168rpx;
		height: 16rpx;
	}

	.shareApp_fd1_1 {
		background: rgba(230, 0, 54, 1);
		margin: 30rpx 22rpx 0rpx 21rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		width: 670rpx;
		padding: 40rpx 56rpx 49rpx 56rpx;
	}

	.shareApp_fd1_0_c2_c1 {
		background: linear-gradient(14deg, #E79D6C 0%, #FEEBCA 49%, #E79D6C 100%);
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor0);
		width: 300rpx;
		height: 80rpx;
		line-height: 80rpx;
		font-weight: 700;
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.shareApp_fd1_0_c2_c0 {
		background: linear-gradient(14deg, #E79D6C 0%, #FEEBCA 49%, #E79D6C 100%);
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor0);
		width: 300rpx;
		height: 80rpx;
		line-height: 80rpx;
		font-weight: 700;
	}

	.shareApp_fd1_0_c2 {
		margin: 100rpx 0rpx 50rpx 0rpx;
	}

	.shareApp_fd1_0_c1 {
		background: linear-gradient(14deg, #E79D6C 0%, #FEEBCA 49%, #E79D6C 100%);
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor0);
		width: 521rpx;
		height: 80rpx;
		line-height: 80rpx;
		font-weight: 700;
	}

	.shareApp_fd1_0_c0 {
		width: 320rpx;
		height: 320rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 20rpx 0rpx 60rpx 0rpx;
	}

	.shareApp_fd1_0 {
		background: url(image-path('224.png')) no-repeat, transparent;
		background-size: 100% auto !important;
		padding: 74rpx 0rpx 0rpx 0rpx;
	}

	.shareApp_flex_2 {
		background: #fff;
		background-size: 100% auto !important;
		border-radius: 16rpx 16rpx 0rpx 0rpx;
	}

	.shareApp_fd2_2 {
		background: rgba(246, 246, 246, 1);
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		font-size: 34rpx;
		color: rgba(17, 17, 17, 1);
		width: 750rpx;
		height: 90rpx;
		line-height: 90rpx;
		font-weight: 400;
	}

	.shareApp_fd2_1_c0_c1 {
		color: #666666;
		font-size: 24rpx;
		font-weight: 400;
		margin: 20rpx 0rpx 0rpx 0rpx;
	}

	.shareApp_fd2_1_c0_c0 {
		width: 90rpx;
		height: 90rpx;
	}

	.shareApp_fd2_1 {
		padding: 0rpx 128rpx 0rpx 152rpx;
		margin: 42rpx 0rpx 80rpx 0rpx;
	}

	.shareApp_fd2_0 {
		color: #111111;
		font-size: 32rpx;
		font-weight: 400;
		line-height: 46rpx;
		margin: 40rpx 32rpx 0rpx 32rpx;
		text-align: center;
	}
</style>